home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Beta / Quicktime 2.0 Beta.iso / Extensions / Macintosh Easy Open / Documentation / Developer / Interfaces / CIncludes / Components.h next >
Encoding:
C/C++ Source or Header  |  1993-04-28  |  8.3 KB  |  275 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3. Created: Wednesday, August 14, 1991 at 12:09 PM
  4.  Components.h
  5.  C Interface to the Macintosh Libraries
  6.  
  7.  
  8.  Copyright Apple Computer, Inc. 1990 - 1993
  9.  All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __COMPONENTS__
  15. #define __COMPONENTS__
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20.  
  21.  
  22. #define    gestaltComponentMgr 'cpnt'
  23.  
  24. #define    kAnyComponentType            0
  25. #define    kAnyComponentSubType        0
  26. #define    kAnyComponentManufacturer    0
  27. #define    kAnyComponentFlagsMask        0
  28.  
  29. enum {
  30.     cmpWantsRegisterMessage = 1L<<31
  31. };
  32.  
  33. struct ComponentDescription {
  34.  OSType componentType;                    /* A unique 4-byte code indentifying the command set */
  35.  OSType componentSubType;                /* Particular flavor of this instance */
  36.  OSType componentManufacturer;            /* Vendor indentification */
  37.  unsigned long componentFlags;            /* 8 each for Component,Type,SubType,Manuf/revision */
  38.  unsigned long componentFlagsMask;        /* Mask for specifying which flags to consider in search, zero during registration */
  39. };
  40.  
  41. typedef struct ComponentDescription ComponentDescription;
  42.  
  43. struct ResourceSpec {
  44.  OSType resType;                        /* 4-byte code  */
  45.  short resId;                            /*    */
  46. };
  47.  
  48. typedef struct ResourceSpec ResourceSpec;
  49.  
  50. struct ComponentResource {
  51.  ComponentDescription cd;                /* Registration parameters */
  52.  ResourceSpec component;                /* resource where Component code is found */
  53.  ResourceSpec componentName;            /* name string resource */
  54.  ResourceSpec componentInfo;            /* info string resource */
  55.  ResourceSpec componentIcon;            /* icon resource */
  56. };
  57.  
  58. typedef struct ComponentResource ComponentResource;
  59. typedef ComponentResource *ComponentResourcePtr, **ComponentResourceHandle;
  60.  
  61. /* Structure received by Component:  */
  62. struct ComponentParameters {
  63.  unsigned char flags;                    /* call modifiers: sync/async, deferred, immed, etc */
  64.  unsigned char paramSize;                /* size in bytes of actual parameters passed to this call */
  65.  short what;                            /* routine selector, negative for Component management calls */
  66.  long params[1];                        /* actual parameters for the indicated routine */
  67. };
  68.  
  69. typedef struct ComponentParameters ComponentParameters;
  70.  
  71.  
  72. struct ComponentRecord {
  73.  long data[1];
  74. };
  75.  
  76. typedef struct ComponentRecord ComponentRecord;
  77. typedef ComponentRecord *Component;
  78.  
  79. struct ComponentInstanceRecord {
  80.  long data[1];
  81. };
  82.  
  83. typedef struct ComponentInstanceRecord ComponentInstanceRecord;
  84. typedef ComponentInstanceRecord *ComponentInstance;
  85.  
  86.  
  87.  
  88. typedef long ComponentResult;
  89.  
  90. typedef pascal ComponentResult (*ComponentRoutine)
  91.   (ComponentParameters *tp, Handle componentStorage );
  92.  
  93. typedef pascal ComponentResult (*ComponentFunction)();
  94.  
  95.  
  96.  
  97.  
  98.  
  99. #define ComponentCallNow( callNumber, paramSize ) \
  100.   {0x2F3C,paramSize,callNumber,0x7000,0xA82A}
  101.  
  102. #ifdef __cplusplus
  103. extern "C" {
  104. #endif
  105.  
  106. /* 
  107.  *******************************************************
  108.  *                                                     *
  109.  *              APPLICATION LEVEL CALLS                *
  110.  *                                                     *
  111.  *******************************************************
  112.  * Component Database Add, Delete, and Query Routines 
  113.  *******************************************************
  114. */
  115.  
  116. pascal Component RegisterComponent(ComponentDescription *cd,ComponentRoutine componentEntryPoint,
  117.  short global,Handle componentName,Handle componentInfo,Handle componentIcon)
  118.  = {0x7001,0xA82A}; 
  119. pascal Component RegisterComponentResource(ComponentResourceHandle tr,short global)
  120.  = {0x7012,0xA82A}; 
  121. pascal OSErr UnregisterComponent(Component aComponent)
  122.  = {0x7002,0xA82A}; 
  123.  
  124. pascal Component FindNextComponent(Component aComponent,ComponentDescription *looking)
  125.  = {0x7004,0xA82A}; 
  126. pascal long CountComponents(ComponentDescription *looking)
  127.  = {0x7003,0xA82A}; 
  128.  
  129. pascal OSErr GetComponentInfo(Component aComponent,ComponentDescription *cd,
  130.  Handle componentName,Handle componentInfo,Handle componentIcon)
  131.  = {0x7005,0xA82A}; 
  132. pascal long GetComponentListModSeed(void)
  133.  = {0x7006,0xA82A}; 
  134.  
  135.  
  136. /* 
  137.  *******************************************************
  138.  * Component Instance Allocation and dispatch routines 
  139.  *******************************************************
  140. */
  141.  
  142. pascal ComponentInstance OpenComponent(Component aComponent)
  143.  = {0x7007,0xA82A}; 
  144. pascal OSErr CloseComponent(ComponentInstance aComponentInstance)
  145.  = {0x7008,0xA82A}; 
  146.  
  147. pascal OSErr GetComponentInstanceError(ComponentInstance aComponentInstance)
  148.  = {0x700A,0xA82A}; 
  149.  
  150. /*  direct calls to the Components  */
  151. pascal long ComponentFunctionImplemented(ComponentInstance ci,short ftnNumber)
  152.  = {0x2F3C,0x2,0xFFFD,0x7000,0xA82A}; 
  153. pascal long GetComponentVersion(ComponentInstance ci)
  154.  = {0x2F3C,0x0,0xFFFC,0x7000,0xA82A}; 
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158.  
  159.  
  160.  
  161. /*****************************************************
  162. *                                                    *
  163. *               CALLS MADE BY Components             *
  164. *                                                    *
  165. ******************************************************
  166. ******************************************************
  167. * Required Component routines
  168. *******************************************************/
  169.  
  170.  
  171. #define kComponentOpenSelect -1            /* ComponentInstance for this open */
  172. #define kComponentCloseSelect -2        /* ComponentInstance for this close */
  173. #define kComponentCanDoSelect -3        /* selector # being queried */
  174. #define kComponentVersionSelect -4        /* no params */
  175. #define kComponentRegisterSelect -5        /* no params */
  176. #define kComponentTargetSelect -6        /* ComponentInstance for top of call chain */
  177.  
  178. #ifdef __cplusplus
  179. extern "C" {
  180. #endif
  181.  
  182. /* 
  183.  *******************************************************
  184.  * Component Management routines
  185.  *******************************************************
  186. */
  187.  
  188. pascal void SetComponentInstanceError(ComponentInstance aComponentInstance,
  189.  OSErr theError)
  190.  = {0x700B,0xA82A}; 
  191.  
  192. pascal long GetComponentRefcon(Component aComponent)
  193.  = {0x7010,0xA82A}; 
  194. pascal void SetComponentRefcon(Component aComponent,long theRefcon)
  195.  = {0x7011,0xA82A}; 
  196.  
  197. pascal short OpenComponentResFile(Component aComponent)
  198.  = {0x7015,0xA82A}; 
  199. pascal OSErr CloseComponentResFile(short refnum)
  200.  = {0x7018,0xA82A}; 
  201.  
  202.  
  203. /* 
  204.  *******************************************************
  205.  * Component Instance Management routines
  206.  *******************************************************
  207. */
  208.  
  209. pascal Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance)
  210.  = {0x700C,0xA82A}; 
  211. pascal void SetComponentInstanceStorage(ComponentInstance aComponentInstance,
  212.  Handle theStorage)
  213.  = {0x700D,0xA82A}; 
  214.  
  215. pascal long GetComponentInstanceA5(ComponentInstance aComponentInstance)
  216.  = {0x700E,0xA82A}; 
  217. pascal void SetComponentInstanceA5(ComponentInstance aComponentInstance,
  218.  long theA5)
  219.  = {0x700F,0xA82A}; 
  220.  
  221. pascal long CountComponentInstances(Component aComponent)
  222.  = {0x7013,0xA82A}; 
  223.  
  224. /*  useful helper routines for convenient method dispatching  */
  225. pascal long CallComponentFunction(ComponentParameters *params,ComponentFunction func)
  226.  = {0x70FF,0xA82A}; 
  227. pascal long CallComponentFunctionWithStorage(Handle storage,ComponentParameters *params,
  228.  ComponentFunction func)
  229.  = {0x70FF,0xA82A}; 
  230. pascal long DelegateComponentCall(ComponentParameters *originalParams,ComponentInstance ci)
  231.  = {0x7024,0xA82A}; 
  232. #ifdef __cplusplus
  233. }
  234. #endif
  235. enum {
  236.  
  237.  
  238. /* Set Default Component flags */
  239.  defaultComponentIdentical = 0,
  240.  defaultComponentAnyFlags = 1,
  241.  defaultComponentAnyManufacturer = 2,
  242.  defaultComponentAnySubType = 4
  243.  
  244. #define defaultComponentAnyFlagsAnyManufacturer defaultComponentAnyFlags+defaultComponentAnyManufacturer
  245. #define defaultComponentAnyFlagsAnyManufacturerAnySubType defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType
  246. };
  247.  
  248. #ifdef __cplusplus
  249. extern "C" {
  250. #endif
  251. pascal OSErr SetDefaultComponent(Component aComponent,short flags)
  252.  = {0x701E,0xA82A}; 
  253. pascal ComponentInstance OpenDefaultComponent( OSType componentType, OSType componentSubType )
  254.  = {0x7021,0xA82A}; 
  255. pascal Component CaptureComponent(Component capturedComponent,Component capturingComponent)
  256.  = {0x701C,0xA82A}; 
  257. pascal OSErr UncaptureComponent(Component aComponent)
  258.  = {0x701D,0xA82A}; 
  259. #ifdef __cplusplus
  260. }
  261. #endif
  262.  
  263. typedef enum {                    /* errors from component manager & components  */
  264.     invalidComponentID = -3000,
  265.     validInstancesExist = -3001,
  266.     componentNotCaptured = -3002,
  267.     componentDontRegister = -3003
  268.     };
  269.  
  270. #define badComponentInstance    0x80008001
  271. #define badComponentSelector    0x80008002
  272.  
  273.  
  274. #endif
  275.